<div id="app">
    <admin-page-header >
        <bi-button type="primary" @click="handleParam">参数设置</bi-button>
    </admin-page-header>
    <div class="container">
        <div class="row g-2">
            <div class="col-12">
                <bi-card title="公共参数">
                    <web-model-param ref="param" :model="$pageData.model_id" no-text="请点击右上角按钮添加公共参数"  :data="value" ></web-model-param>
                    
                    <template #footer>
                        <bi-button type="primary" @click="save">保存</bi-button>
                    </template>
                
                </bi-card>
            </div>
        </div>
    </div>
</div>

<script>
import paramListDialog from 'model/param-list-dialog.vue';
import webModelParam from 'field/model-param.vue';
let app = admin.createApp({
    components:{
        webModelParam,
    },
    data(){

        let value  = {};
        if (this.$pageData.value) value = this.$pageData.value;
        console.log(value);
        return {
            value
        }
    },
    watch:{

    },
    methods:{
        save(){
            
            this.$ajax({
                url:this.$url({action:'save'}),
                data:{
                    value:this.$refs.param.getData()
                },
                success:(res)=>{
                    this.$toast('保存成功');
                }
            });  
        },
        handleParam(){
        //    this.$go({action:'param',gets:{model_id:item.model_id}});
            this.$dialog({
                type:'vue',
                content:admin.createApp(paramListDialog,{model_id:this.$pageData.model_id}),
                callback:()=>{
                    this.$refs.param.refresh();
                }
            });
        }
    }
}).mount('#app');
</script>